<template>
    <div>
        <van-nav-bar title="首页" />
        <!-- 标签栏 -->
        <van-tabs v-model:active="active" animated>
            <van-tab title="推荐">
                <van-search v-model="value" shape="round" placeholder="请输入搜索关键词"  @click="ss"/>
            </van-tab>
            <van-tab title="特惠">内容 2</van-tab>
            <van-tab title="美妆">内容 3</van-tab>
            <van-tab title="零食">内容 4</van-tab>
        </van-tabs>
        <!-- 轮播图 -->
        <van-swipe :autoplay="3000" lazy-render>
            <van-swipe-item v-for="image in images" :key="image">
                <img :src="image" style="width: 150px;height: 150px;" />
            </van-swipe-item>
        </van-swipe>
        <!-- 导航 -->
        <van-grid :column-num="4">
            <van-grid-item v-for="item in catitems" :icon="item.image_src" :text="item.name" />
        </van-grid>

        <div v-for="item in floordata">
            <img :src="item.floor_title.image_src" alt="">
            <div v-for="item in item.product_list">
                <img :src="item.image_src" alt=""  style="width: 140px; height: 130px; float: left;">
            </div>
        </div>
    </div>
</template>

<script setup>
// 标签栏
import { ref } from 'vue';
const active = ref(0);

// 轮播图
const images = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-3.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-4.jpeg',
];

// 导航
import { catitemsApi, floordataApi } from '@/api/api';
import router from '@/router';
let catitems = ref([])
catitemsApi().then(res => {
    console.log('导航数据', res)
    catitems.value = res.data.message
})

// 楼层
let floordata = ref([])
floordataApi().then(res => {
    console.log('楼层数据', res)
    floordata.value = res.data.message
})

// 搜索
let ss=()=>{
    router.push('/ss')
}
</script>

<style lang="scss" scoped></style>